<%--
  - Copyright 2011 Angel Sanadinov
  -
  - This file is part of VBox WMI.
  -
  - VBox WMI is free software: you can redistribute it and/or modify
  - it under the terms of the GNU General Public License as published by
  - the Free Software Foundation, either version 3 of the License, or
  - (at your option) any later version.
  -
  - VBox WMI is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU General Public License for more details.
  -
  - You should have received a copy of the GNU General Public License
  - along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
  --%>

<%@page import="Utilities.UIFunctions"%>
<%@page import="Utilities.ParameterNames"%>
<%@page import="Beans.Requests.LogoutRequest"%>
<%@page import="Managers.Utilities.User"%>
<%
    //retrieves user data from the session
    User userObj = (User)session.getAttribute(ParameterNames.SESSION_USER_OBJECT);

    //checks if the user is logged in (data object is in the session)
    if(userObj != null)
    {
        //builds and sends the logout request
        LogoutRequest logoutRequest = new LogoutRequest(userObj.getUserData().getUserId(), session);
        UIFunctions.sendServiceRequest(request, response, logoutRequest, ParameterNames.Service.LOGOUT_MANAGEMENT);
    }
    else
        ;

    response.sendRedirect("index.jsp");
%>